<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{
                padding: 0px;
                margin: 0px;
            }
            .a{
                margin:0px auto;
                background: lightblue;
            }

        </style>
    </head>
    <body>
        <div class="a">
            <h1 id="txt">开始抽奖吧</h1>
            <button id="start">开始</button>
            <button id="end">停止</button>
        </div>
        <div class="b">
            
        </div>
        <div class="c">
            <h2 id="t"></h2>
        </div>
        <script>
            var txt=document.getElementById("txt")
            var t=document.getElementById("t")
            var start=document.getElementById("start")
            var end=document.getElementById("end")
            var timer
            var list=["张三","a","b"]

            
            console.log(list[0])
            console.log(list.length)
            start.onclick=function(){
                clearInterval(timer)
               timer=setInterval(function(){
                    var n=parseInt(Math.random()*list.length);
                    txt.innerHTML=list[n];
                },100)
            }
            end.onclick=function(){
                clearInterval(timer);
            }
           
        </script>
    </body>
</html>